#ifndef QNBEXCAMERA_H
#define QNBEXCAMERA_H

#include <QObject>
#include <QImage>
#include "escapi.h"

#ifdef _WINXP
#include <QMutex>
#include <QMutexLocker>
#else
#include <QCamera>
#endif

typedef enum {
    CAPTURED_FOR_VIDEO,
    CAPTURED_FOR_OTHERS,
} CAPTURE_TYPE;

#ifdef _WINXP
class QNBExCamera : public QObject
{
    Q_OBJECT
public:
    explicit QNBExCamera(int width, int height, QObject *parent = 0);
    ~QNBExCamera();
    int initialize();
    void deinitialize();
    int capture(CAPTURE_TYPE type = CAPTURED_FOR_OTHERS);
    const QImage& getImage() const { return image2_; }
    const int* getImageRaw() const { return capture_.mTargetBuf; }

private:
    int width_;
    int height_;
    struct SimpleCapParams capture_;
    QImage image_;
    QImage image2_;
    QMutex m_frameMutex;

signals:
    void Captured(QImage image);

public slots:

};
#else
class QNBExCamera : public QCamera
{
    Q_OBJECT
public:
    explicit QNBExCamera(int width, int height, QObject *parent = 0);
    ~QNBExCamera();
};
#endif

#endif // QNBEXCAMERA_H
